/*
 * 页面浏览信息
 *
 * $Date: 2015/01/23 10:10:30 $
 * $anthor: xuxueli $
 */

var platform = 0;		// 操作平台:0-PC、1-Android、2-IOS
var appName;			// 浏览器名称
var appVersion;			// 浏览器版本
var appOsPlatform;		// 浏览器.操作系统
var ifJavaEnabled;		// 浏览器.是否支持Java
(function(){
	
	// 操作平台:0-PC、1-Android、2-IOS
	if(navigator.userAgent.indexOf('Android') > -1){
		platform = 1;
	}else if(navigator.userAgent.indexOf('Mac OS') > -1){
		platform = 2;
	}
	
	// 浏览器检测
	var Sys = {};
    var ua = navigator.userAgent.toLowerCase();
    
    try {
		if (window.ActiveXObject)
			Sys.ie = ua.match(/msie ([\d.]+)/)[1];
		else if (document.getBoxObjectFor)
			Sys.firefox = ua.match(/firefox\/([\d.]+)/)[1];
		else if (window.MessageEvent && !document.getBoxObjectFor)
			Sys.chrome = ua.match(/chrome\/([\d.]+)/)[1];
		else if (window.opera)
			Sys.opera = ua.match(/opera.([\d.]+)/)[1];
		else if (window.openDatabase)
			Sys.safari = ua.match(/version\/([\d.]+)/)[1];
		;
	} catch (e) {}
	
	if(Sys.ie) {
    	appName = "IE";			// 浏览器名称
    	appVersion = Sys.ie;	// 浏览器版本
    } else if(Sys.firefox) {
    	appName = "Firefox";
    	appVersion = Sys.firefox;
    } else if(Sys.chrome) {
    	appName = "Chrome";
    	appVersion = Sys.chrome;
    } else if(Sys.opera) {
    	appName = "Opera";
    	appVersion = Sys.opera;
    } else if(Sys.safari) {
    	appName = "Safari";
    	appVersion = Sys.safari;
    } else {
    	appName = "未知";
    	appVersion = "未知";
    	
    	return;
    }
    
    appOsPlatform = navigator.platform;				// 浏览器.操作系统
    ifJavaEnabled = navigator.javaEnabled()?1:0;	// 浏览器.是否支持Java
    
    /*
	var cookieKey = "puic-pay-log-browser";
	var cookieVar = getCookie(cookieKey);
	if (cookieVar == null) {
		console.log("platform:" + platform);
		console.log("appName:" + appName);
		console.log("appVersion:" + appVersion);
		console.log("app_os_platform:" + app_os_platform);
		console.log("ifJavaEnabled:" + ifJavaEnabled);
	}
	
	setCookie("key", "value", 999999);
	
	*/
	
})();
